from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get('https:www.baidu.com')
# xpath定位标签和属性,
kw = driver.find_element(By.XPATH, '//form/span/input')  # 层级定位
print(kw.get_attribute('outerHTML'))

# 关闭浏览器
driver.quit()
